<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">

	<ui:define name="content">
		<f:event type="preRenderView"
			listener="#{trainingController.beforeEdit}" />
		<div class="title ui-widget-header ui-corner-all">
			<h:panelGrid style="margin:auto;">
		EDITAR CAPACITACIÓN
		</h:panelGrid>

		</div>
		<h:form id="formEdit">
			<h:panelGrid style="margin:auto;">

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:messages id="messages"></p:messages>

				</h:panelGrid>

				<h:panelGrid columns="4">

					<p:outputLabel value="Postulante: "></p:outputLabel>
					<p:outputLabel
						value="#{trainingController.trainingSelected.interview.candidate.firstname} #{trainingController.trainingSelected.interview.candidate.lastname}"
						id="name"></p:outputLabel>

					<p:outputLabel value="Entrevista: "></p:outputLabel>
					<p:outputLabel
						value="#{trainingController.trainingSelected.interview.id}"
						id="interview_id"></p:outputLabel>

					<p:outputLabel value="DNI: "></p:outputLabel>
					<p:outputLabel
						value="#{trainingController.trainingSelected.interview.candidate.documentNumber}"
						id="document_number"></p:outputLabel>

					<p:outputLabel value=""></p:outputLabel>
					<p:outputLabel value=""></p:outputLabel>

					<p:spacer height="4"></p:spacer>
					<p:spacer height="4"></p:spacer>
					<p:spacer height="4"></p:spacer>
					<p:spacer height="4"></p:spacer>


					<p:outputLabel value="Estado"></p:outputLabel>
					<p:selectOneMenu value="#{trainingController.stateSelected}" 
					disabled="#{!trainingController.isPending}"
						required="true" requiredMessage="Debe seleccionar Estado">
						<f:selectItems value="#{trainingController.states}"></f:selectItems>
						<p:ajax listener="#{trainingController.onChangeState}"
							update=":formEdit:calendarLabel :formEdit:calendarValue
							:formEdit:messages"></p:ajax>
					</p:selectOneMenu>
					
					<h:panelGroup id="calendarLabel">
						<p:outputLabel value="Fecha de OJT"
							rendered="#{trainingController.isGoal}"></p:outputLabel>
						<p:outputLabel value=""
							rendered="#{!trainingController.isGoal}"></p:outputLabel>	
					</h:panelGroup>
					
					<h:panelGroup id="calendarValue">
						<p:calendar rendered="#{trainingController.isGoal}"
							value="#{trainingController.ojtAt}" 
							disabled="#{!trainingController.fromOnChange}"
							pattern="dd-MM-yyyy hh:mm:ss a" required="true" stepMinute="10"
							requiredMessage="Debe seleccionar fecha de OJT">
						</p:calendar>
						<p:outputLabel value=""
							rendered="#{!trainingController.isGoal}"></p:outputLabel>
					</h:panelGroup>

					<p:outputLabel value="Capacitador"></p:outputLabel>
					<p:selectOneMenu id="trainers" disabled="#{!trainingController.isPending}"
						value="#{trainingController.trainerSelected}">
						<f:selectItem itemValue="" itemLabel="Seleccione"></f:selectItem>
						<f:selectItems value="#{trainingController.trainers}"></f:selectItems>
					</p:selectOneMenu>

					<p:outputLabel value="Fecha de Capacitación"></p:outputLabel>
					<p:calendar disabled="#{!trainingController.isPending}"
						value="#{trainingController.trainingSelected.trainingAt}"
						pattern="dd-MM-yyyy hh:mm:ss a" required="true" stepMinute="10"
						requiredMessage="Debe seleccionar fecha de capacitación">
					</p:calendar>


					<p:outputLabel value="Comentarios:"></p:outputLabel>
					<p:inputTextarea
						value="#{trainingController.trainingSelected.comment}" rows="4"
						cols="30"></p:inputTextarea>

				</h:panelGrid>

				<h:panelGrid style="margin:auto;text-align:center;">
					<p:commandButton action="#{trainingController.edit}" value="Editar"
						ajax="false">
					</p:commandButton>
				</h:panelGrid>
			</h:panelGrid>
		</h:form>
	</ui:define>

</ui:composition>
</html>
